﻿using System.Collections.Generic;
using NetBay.Core.BusinessEntities;
using Rio.Framework.Pages.Context;
using Rio.Framework.Pages.Enums;

namespace Rio.Framework.Pages
{

    /// <summary>
    /// Copy - Paste Clipboard
    /// </summary>
    public class CopyPasteClipboard
    {

        #region Properties

        /// <summary>
        ///  Gets or Sets Action type
        /// </summary>
        public PasteCopyActionType ActionType { get; set; }

        /// <summary>
        /// Gets or Sets the list of Documents Ids
        /// </summary>
        public List<long> Documents { get; set; }

        /// <summary>
        /// Gets or Sets source folder type
        /// </summary>
        public Folder SourceFolder { get; set; }

        /// <summary>
        /// Returns a value indicating whether there is document(s) in the clipboard
        /// </summary>
        public bool HasDocument
        {
            get
            {
                if (this.Documents.Count > 0)
                    return true;
                else
                    return false;
            }
        }

        /// <summary>
        /// Returns a value indicating whether the document is an old version
        /// </summary>
        public bool IsOriginalVersion { get; set; }

        /// <summary>
        /// Gets or sets version id
        /// </summary>
        public long VersionIdentifier { get; set; }

        #endregion

        #region Constructors

        public CopyPasteClipboard()
        {
            this.Documents = new List<long>();
        }

        #endregion

        #region Public functions

        /// <summary>
        /// Add a document to the clipboard
        /// </summary>
        /// <param name="id"></param>
        public void AddDocument(long id)
        {
            this.Documents.Add(id);
        }

        /// <summary>
        /// Remove a document to the clipboard
        /// </summary>
        /// <param name="id"></param>
        public void RemoveDocument(long id)
        {
            this.Documents.Remove(id);
            Clean();
        }

        /// <summary>
        /// Clear the list of documents and action 
        /// </summary>
        public void ClearDocuments()
        {
            this.ActionType = PasteCopyActionType.None;
            this.Documents.Clear();
            this.SourceFolder = null;
            this.IsOriginalVersion = false;
        }

        /// <summary>
        /// Cleans this instance and ensure that the instance is in a valid state.
        /// </summary>
        public void Clean()
        {
            if (Documents.Count == 0)
            {
                ClearDocuments();
            }
        }
        #endregion

    }
}
